package com.lbn.jfqsc.widget;

import com.qiniu.android.common.Zone;
import com.qiniu.android.storage.Configuration;
import com.qiniu.android.storage.UploadManager;

/**
 * Created by 李炳南
 * 2017/3/5.
 */

public class UploadFactory {

    private static UploadFactory factory;

    private UploadFactory(){}

    public static UploadFactory instance(){

        if(factory==null){
            synchronized (UploadFactory.class){
                if(factory==null){
                    factory = new UploadFactory();
                }
            }
        }
        return factory;
    }

    public UploadManager uploadManager(){
        Configuration config = new Configuration.Builder()
//                .chunkSize(256 * 1024)  //分片上传时，每片的大小。 默认256K
//                .putThreshhold(512 * 1024)  // 启用分片上传阀值。默认512K
//                .connectTimeout(10) // 链接超时。默认10秒
//                .responseTimeout(60) // 服务器响应超时。默认60秒
//                .recorder(recorder)  // recorder分片上传时，已上传片记录器。默认null
//                .recorder(recorder, keyGen)  // keyGen 分片上传时，生成标识符，用于片记录器区分是那个文件的上传记录
                .zone(Zone.httpAutoZone) // 设置区域，指定不同区域的上传域名、备用域名、备用IP。
                .build();
        // 重用uploadManager。一般地，只需要创建一个uploadManager对象
        UploadManager uploadManager = new UploadManager(config);
        return uploadManager;
    }


}
